//search模块小仓库
import { reqGetSearchInfo } from "@/api"
const state = {
    searchList: {},
}


const mutations = {
    GETSEARCHLIST(state, searchList) {
        state.searchList = searchList;
    }
}


const actions = {
    //获取search模块数据
    async getSearchList({ commit }, params) {
        //params至少是一个空对象
        let result = await reqGetSearchInfo(params);
        if (result.code == 200) {
            commit('GETSEARCHLIST', result.data);
        }
    }
}


//把将来组件中需要使用的数据简化，将来不需要写一长串
const getters = {
    //当前中的state，并非大仓库中的state
    goodsList(state) {
        return state.searchList.goodsList || [];
    },
    trademarkList(state){
        return state.searchList.trademarkList;
    },
    attrsList(state){
        return state.searchList.attrsList
    }
}


export default {
    state, mutations, actions, getters
}